﻿using ALiOssNet6;

using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.RazorPages;

using System.Diagnostics;
using System.Text;

namespace ALiOssNet6Demo.Pages
{
    public class IndexModel : PageModel
    {
        private readonly ILogger<IndexModel> _logger;

        public IndexModel(ILogger<IndexModel> logger)
        {
            _logger = logger;
        }

        public async Task OnGetAsync([FromServices] IOss oss)
        {
            Stopwatch sw = Stopwatch.StartNew();
            var ret = await oss.SaveAsync("ykota", "a", Encoding.UTF8.GetBytes(new String('a',1024*1024)));
            _logger.LogInformation($"Save Result:{ret};Elapsed:{sw.Elapsed}");
            sw.Restart();
            var bytes = await oss.GetAsync("ykota", "a");
            _logger.LogInformation($"Get Result:{bytes?.Length ?? 0};Elapsed:{sw.Elapsed}");

        }
    }
}